<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    手写板源码 |  Yolin
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="/favicon.png" />
  
  
<link rel="stylesheet" href="/css/style.css">

  
<script src="/js/pace.min.js"></script>


  

  

<link rel="alternate" href="/atom.xml" title="Yolin" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content">
      <section class="outer">
  <article id="post-手写板源码" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  手写板源码
</h1>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/03/30/%E6%89%8B%E5%86%99%E6%9D%BF%E6%BA%90%E7%A0%81/" class="article-date">
  <time datetime="2020-03-30T03:00:02.000Z" itemprop="datePublished">2020-03-30</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%B0%8F%E7%A8%8B%E5%BA%8F/">小程序</a>
  </div>

      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">893字</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">5分钟</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/zj.jpg" alt=""></p>
<a id="more"></a>
<h2 id="sxb-wxml"><a href="#sxb-wxml" class="headerlink" title="sxb.wxml"></a>sxb.wxml</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">&lt;view <span class="class"><span class="keyword">class</span></span>=<span class="string">"contain"</span>&gt;</span><br><span class="line">	&lt;view&gt;绘制你的图案&lt;<span class="regexp">/view&gt;</span></span><br><span class="line"><span class="regexp">	&lt;canvas canvas-id="canvas" class="canvas"</span></span><br><span class="line"><span class="regexp">	bindtouchstart="start" bindtouchmove="move" bindtouchend="end"&gt;&lt;/</span>canvas&gt;</span><br><span class="line">	&lt;text&gt;坐 标: (&#123;&#123;x1&#125;&#125;,&#123;&#123;y1&#125;&#125;)&lt;<span class="regexp">/text&gt;</span></span><br><span class="line"><span class="regexp">&lt;/</span>view&gt;</span><br><span class="line">&lt;view <span class="class"><span class="keyword">class</span></span>=<span class="string">"menu"</span>&gt;</span><br><span class="line">	&lt;button bindtap=<span class="string">"clear"</span>&gt;清除画板&lt;<span class="regexp">/button&gt;</span></span><br><span class="line"><span class="regexp">	&lt;button bindtap="changecolor"&gt;画笔颜色&lt;/</span>button&gt;</span><br><span class="line">	&lt;view <span class="class"><span class="keyword">class</span></span>=<span class="string">"view2"</span> style=<span class="string">"&#123;&#123;animate&#125;&#125;"</span> hidden=<span class="string">"&#123;&#123;yincang&#125;&#125;"</span>&gt;</span><br><span class="line">		&lt;view <span class="class"><span class="keyword">class</span></span>=<span class="string">"red"</span> bindtap=<span class="string">"red"</span>&gt;&lt;<span class="regexp">/view&gt;</span></span><br><span class="line"><span class="regexp">		&lt;view class="yellow" bindtap="yellow"&gt;&lt;/</span>view&gt;</span><br><span class="line">		&lt;view <span class="class"><span class="keyword">class</span></span>=<span class="string">"blue"</span> bindtap=<span class="string">"blue"</span>&gt;&lt;<span class="regexp">/view&gt;</span></span><br><span class="line"><span class="regexp">		&lt;view class="eee" bindtap="eee"&gt;&lt;/</span>view&gt;</span><br><span class="line">		&lt;view <span class="class"><span class="keyword">class</span></span>=<span class="string">"black"</span> bindtap=<span class="string">"black"</span>&gt;&lt;<span class="regexp">/view&gt;</span></span><br><span class="line"><span class="regexp">		&lt;view class="water" bindtap="water"&gt;&lt;/</span>view&gt;</span><br><span class="line">		&lt;view <span class="class"><span class="keyword">class</span></span>=<span class="string">"zi"</span> bindtap=<span class="string">"zi"</span>&gt;&lt;<span class="regexp">/view&gt;</span></span><br><span class="line"><span class="regexp">	&lt;/</span>view&gt;</span><br><span class="line">	&lt;button bindtap=<span class="string">"changewidth"</span>&gt;粗细&lt;<span class="regexp">/button&gt;</span></span><br><span class="line"><span class="regexp">	&lt;view class="view3" style="&#123;&#123;animate2&#125;&#125;" hidden="&#123;&#123;yincang2&#125;&#125;"&gt;</span></span><br><span class="line"><span class="regexp">		&lt;view class="line-width" bindtap="xi"&gt;细&lt;/</span>view&gt;</span><br><span class="line">		&lt;view <span class="class"><span class="keyword">class</span></span>=<span class="string">"line-width"</span> bindtap=<span class="string">"zx"</span>&gt;中细&lt;<span class="regexp">/view&gt;</span></span><br><span class="line"><span class="regexp">		&lt;view class="line-width" bindtap="pt"&gt;普通&lt;/</span>view&gt;</span><br><span class="line">		&lt;view <span class="class"><span class="keyword">class</span></span>=<span class="string">"line-width"</span> bindtap=<span class="string">"zc"</span>&gt;中粗&lt;<span class="regexp">/view&gt;</span></span><br><span class="line"><span class="regexp">		&lt;view class="line-width" bindtap="c"&gt;粗&lt;/</span>view&gt;</span><br><span class="line">	&lt;<span class="regexp">/view&gt;</span></span><br><span class="line"><span class="regexp">&lt;/</span>view&gt;</span><br></pre></td></tr></table></figure>
<h2 id="sxb-wxss"><a href="#sxb-wxss" class="headerlink" title="sxb.wxss"></a>sxb.wxss</h2><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">@import</span> <span class="string">"../../animate.wxss"</span>;</span><br><span class="line"><span class="selector-tag">page</span>&#123;</span><br><span class="line">  <span class="attribute">height</span>: <span class="number">100%</span>;</span><br><span class="line">  <span class="attribute">background-color</span>: <span class="number">#fffbf0</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.contain</span>&#123;</span><br><span class="line">  </span><br><span class="line">  <span class="attribute">display</span>: flex;</span><br><span class="line">  <span class="attribute">flex-direction</span>: column;</span><br><span class="line">  <span class="attribute">align-items</span>: center;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.canvas</span>&#123;</span><br><span class="line">  <span class="attribute">background-color</span>: white;</span><br><span class="line">  <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line">  <span class="attribute">width</span>: <span class="number">96%</span>;</span><br><span class="line">  <span class="attribute">height</span>: <span class="number">600</span>rpx;</span><br><span class="line">  <span class="attribute">box-sizing</span>: border-box;</span><br><span class="line">  <span class="attribute">box-shadow</span>:<span class="number">11</span>rpx <span class="number">11</span>rpx <span class="number">11</span>rpx gray;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">text</span>&#123;</span><br><span class="line">  <span class="attribute">margin-top</span>: <span class="number">15</span>rpx;</span><br><span class="line">  <span class="attribute">font-size</span>: <span class="number">35</span>rpx;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">button</span>&#123;</span><br><span class="line">  <span class="attribute">box-shadow</span>: <span class="number">11</span>rpx <span class="number">11</span>rpx <span class="number">11</span>rpx gray;</span><br><span class="line">  <span class="attribute">margin-bottom</span>: <span class="number">20</span>rpx;</span><br><span class="line">  <span class="attribute">width</span>: <span class="number">200</span>rpx;</span><br><span class="line">  <span class="attribute">line-height</span>: <span class="number">60</span>rpx;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.view2</span>&#123;</span><br><span class="line">  <span class="attribute">width</span>: <span class="number">80%</span>;</span><br><span class="line">  <span class="attribute">height</span>: <span class="number">60</span>rpx;</span><br><span class="line">  <span class="attribute">display</span>: flex;</span><br><span class="line">  <span class="attribute">flex-direction</span>: row;</span><br><span class="line">  <span class="attribute">margin</span>: <span class="number">0</span> auto;</span><br><span class="line">  <span class="attribute">text-align</span>: center;</span><br><span class="line">  <span class="comment">/* animation: zoomIn 2.5s; */</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.view2</span> <span class="selector-tag">view</span>&#123;</span><br><span class="line">  <span class="comment">/* border: 1rpx solid black; */</span></span><br><span class="line">  <span class="attribute">flex</span>: <span class="number">1</span>;</span><br><span class="line">  <span class="attribute">margin-left</span>: <span class="number">30</span>rpx;</span><br><span class="line">  <span class="attribute">border-radius</span>: <span class="number">50%</span>;</span><br><span class="line">  <span class="attribute">margin-bottom</span>: <span class="number">10</span>rpx;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.red</span>&#123;</span><br><span class="line">  <span class="attribute">background-color</span>: red;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.yellow</span>&#123;</span><br><span class="line">  <span class="attribute">background-color</span>: yellow;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.blue</span>&#123;</span><br><span class="line">  <span class="attribute">background-color</span>: <span class="number">#3AC2F1</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.eee</span>&#123;</span><br><span class="line">  <span class="attribute">background-color</span>: green;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.black</span>&#123;</span><br><span class="line">  <span class="attribute">background-color</span>: black;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.water</span>&#123;</span><br><span class="line">  <span class="attribute">background-color</span>: <span class="number">#88ada6</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.zi</span>&#123;</span><br><span class="line">  <span class="attribute">background-color</span>: <span class="number">#725e82</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.menu</span>&#123;</span><br><span class="line">  <span class="attribute">margin-top</span>: <span class="number">20</span>rpx;</span><br><span class="line">  <span class="comment">/* background-color: burlywood; */</span></span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.view3</span>&#123;</span><br><span class="line">  <span class="attribute">display</span>: flex;</span><br><span class="line">  <span class="attribute">width</span>: <span class="number">90%</span>;</span><br><span class="line">  <span class="attribute">margin</span>: <span class="number">0</span> auto;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.line-width</span>&#123;</span><br><span class="line">  <span class="attribute">flex</span>: <span class="number">1</span>;</span><br><span class="line">  <span class="attribute">text-align</span>: center;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="sxb-js"><a href="#sxb-js" class="headerlink" title="sxb.js"></a>sxb.js</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> cvs = <span class="literal">null</span>;</span><br><span class="line"><span class="keyword">var</span> touchs=[];</span><br><span class="line">Page(&#123;</span><br><span class="line">  data: &#123;</span><br><span class="line">    x1:<span class="number">0</span>,</span><br><span class="line">    y1:<span class="number">0</span>,</span><br><span class="line">    linecolor: <span class="string">"black"</span>,</span><br><span class="line">    linewidth:<span class="number">3</span>,</span><br><span class="line">    animate:<span class="string">""</span>,</span><br><span class="line">    animate2:<span class="string">""</span>,</span><br><span class="line">    yincang:<span class="literal">true</span>,</span><br><span class="line">    yincang2:<span class="literal">true</span></span><br><span class="line">  &#125;,</span><br><span class="line">  start:<span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      x1:<span class="built_in">Math</span>.floor(e.touches[<span class="number">0</span>].x),</span><br><span class="line">      y1:<span class="built_in">Math</span>.floor(e.touches[<span class="number">0</span>].y)</span><br><span class="line">    &#125;)</span><br><span class="line">    <span class="keyword">let</span> point=&#123; <span class="attr">x</span>:e.touches[<span class="number">0</span>].x,<span class="attr">y</span>:e.touches[<span class="number">0</span>].y&#125; </span><br><span class="line">    touchs.push(point)</span><br><span class="line">  &#125;,</span><br><span class="line">  move:<span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      x1:<span class="built_in">Math</span>.floor(e.touches[<span class="number">0</span>].x),</span><br><span class="line">      y1:<span class="built_in">Math</span>.floor(e.touches[<span class="number">0</span>].y)</span><br><span class="line">    &#125;)</span><br><span class="line">    <span class="built_in">console</span>.log(touchs.length)</span><br><span class="line">    <span class="keyword">let</span> point=&#123; <span class="attr">x</span>:e.touches[<span class="number">0</span>].x,<span class="attr">y</span>:e.touches[<span class="number">0</span>].y&#125; </span><br><span class="line">    touchs.push(point)</span><br><span class="line">      <span class="keyword">this</span>.draw(touchs)</span><br><span class="line">  &#125;,</span><br><span class="line">  end:<span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span>&#123;</span><br><span class="line">  <span class="comment">//  touchs.pop()</span></span><br><span class="line">  touchs=[]</span><br><span class="line">  &#125;,</span><br><span class="line">  draw:<span class="function"><span class="keyword">function</span>(<span class="params">touchs</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">var</span> point1=touchs[<span class="number">0</span>];</span><br><span class="line">    <span class="keyword">var</span> point2=touchs[<span class="number">1</span>];</span><br><span class="line">    cvs.moveTo(point1.x,point1.y);</span><br><span class="line">    cvs.lineTo(point2.x,point2.y);</span><br><span class="line">    cvs.stroke();</span><br><span class="line">    cvs.draw(<span class="literal">true</span>);</span><br><span class="line">    touchs.shift();</span><br><span class="line">  &#125;,</span><br><span class="line">  onLoad: <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">    cvs=wx.createCanvasContext(<span class="string">'canvas'</span>);</span><br><span class="line">    <span class="comment">// cvs.beginPath();</span></span><br><span class="line">    cvs.setStrokeStyle(<span class="keyword">this</span>.data.linecolor);  </span><br><span class="line">    cvs.setLineWidth(<span class="keyword">this</span>.data.linewidth);  </span><br><span class="line">    cvs.setLineCap(<span class="string">'round'</span>);  </span><br><span class="line">    cvs.setLineJoin(<span class="string">'round'</span>); </span><br><span class="line">  &#125;,</span><br><span class="line">  clear:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    cvs.clearRect(<span class="number">0</span>,<span class="number">0</span>,<span class="number">750</span>,<span class="number">600</span>);</span><br><span class="line">    cvs.draw(<span class="literal">true</span>);</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      x1:<span class="number">0</span>,</span><br><span class="line">      y1:<span class="number">0</span></span><br><span class="line">    &#125;)</span><br><span class="line">  &#125;,</span><br><span class="line">  red:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linecolor:<span class="string">"red"</span>,</span><br><span class="line">      yincang:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setStrokeStyle(<span class="keyword">this</span>.data.linecolor);</span><br><span class="line">  &#125;,</span><br><span class="line">  yellow:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linecolor:<span class="string">"yellow"</span>,</span><br><span class="line">      yincang:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setStrokeStyle(<span class="keyword">this</span>.data.linecolor);</span><br><span class="line">  &#125;,</span><br><span class="line">  blue:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linecolor:<span class="string">"#3AC2F1"</span>,</span><br><span class="line">      yincang:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setStrokeStyle(<span class="keyword">this</span>.data.linecolor);</span><br><span class="line">  &#125;,</span><br><span class="line">  eee:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linecolor:<span class="string">"green"</span>,</span><br><span class="line">      yincang:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setStrokeStyle(<span class="keyword">this</span>.data.linecolor);</span><br><span class="line">  &#125;,</span><br><span class="line">  black:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linecolor:<span class="string">"black"</span>,</span><br><span class="line">      yincang:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setStrokeStyle(<span class="keyword">this</span>.data.linecolor)</span><br><span class="line">  &#125;,</span><br><span class="line">  water:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linecolor:<span class="string">"#88ada6"</span>,</span><br><span class="line">      yincang:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setStrokeStyle(<span class="keyword">this</span>.data.linecolor)</span><br><span class="line">  &#125;,</span><br><span class="line">  zi:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linecolor:<span class="string">"#725e82"</span>,</span><br><span class="line">      yincang:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setStrokeStyle(<span class="keyword">this</span>.data.linecolor)</span><br><span class="line">  &#125;,</span><br><span class="line">  changecolor:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">     yincang:!<span class="keyword">this</span>.data.yincang,</span><br><span class="line">     animate: <span class="string">"animation:zoomIn 1s"</span></span><br><span class="line">    &#125;)</span><br><span class="line">  &#125;,</span><br><span class="line">  changewidth:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">     yincang2:!<span class="keyword">this</span>.data.yincang2,</span><br><span class="line">     animate2: <span class="string">"animation:zoomIn 1s"</span></span><br><span class="line">    &#125;)</span><br><span class="line">  &#125;,</span><br><span class="line">  xi:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linewidth:<span class="number">1</span>,</span><br><span class="line">      yincang2:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setLineWidth(<span class="keyword">this</span>.data.linewidth)</span><br><span class="line">  &#125;,</span><br><span class="line">  zx:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linewidth:<span class="number">2</span>,</span><br><span class="line">      yincang2:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setLineWidth(<span class="keyword">this</span>.data.linewidth)</span><br><span class="line">  &#125;,</span><br><span class="line">  pt:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linewidth:<span class="number">3</span>,</span><br><span class="line">      yincang2:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setLineWidth(<span class="keyword">this</span>.data.linewidth)</span><br><span class="line">  &#125;,</span><br><span class="line">  zc:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linewidth:<span class="number">4</span>,</span><br><span class="line">      yincang2:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setLineWidth(<span class="keyword">this</span>.data.linewidth)</span><br><span class="line">  &#125;,</span><br><span class="line">  c:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.setData(&#123;</span><br><span class="line">      linewidth:<span class="number">5</span>,</span><br><span class="line">      yincang2:<span class="literal">true</span></span><br><span class="line">    &#125;)</span><br><span class="line">    cvs.setLineWidth(<span class="keyword">this</span>.data.linewidth)</span><br><span class="line">  &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/canvas/" rel="tag">canvas</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/2020/05/19/Java%E8%BF%9E%E6%8E%A5mysql-jdbc/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            java数据库连接（jdbc）
          
        </div>
      </a>
    
    
      <a href="/2020/03/26/%E5%AE%9A%E5%88%B6Hadoop%E5%90%AF%E5%8A%A8%E8%84%9A%E6%9C%AC/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">定制Hadoop启动脚本</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        notify: false,
        verify: '',
        app_id: '',
        app_key: '',
        path: window.location.pathname,
        avatar: 'mp',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul class="list-inline">
      <li>
        &copy;
        2020-2021
        张金
      </li>
      <li>
        
      </li>
    </ul>
    <ul class="list-inline">
      <li>
        
        
        <span>
  <i>PV:<span id="busuanzi_value_page_pv"></span></i>
  <i>UV:<span id="busuanzi_value_site_uv"></span></i>
</span>
        
      </li>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
        <img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/beian.png">
        <a href="https://beian.miit.gov.cn"  style="color:#f72b07" target="_blank">陕ICP备20002449号</a>
      </li>

    </ul>
  </div>
</footer>
    <div class="to_top">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>
      </div>
    </main>
      <aside class="sidebar">
        <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="Yolin"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/playlist">歌单</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/video">视频</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/about">关于我</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友情链接</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
      </aside>
      <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
      
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/jquery.justifiedGallery.min.js"></script>


<script src="/js/lazyload.min.js"></script>


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<script src="/js/share.js"></script>




<script>
  try {
    var typed = new Typed("#subtitle", {
    strings: ['肠断月明红豆蔻,','月似当时,','人似当时否？'],
    startDelay: 1500,
    typeSpeed: 200,
    loop: true,
    backSpeed: 40,
    showCursor: true
    });
  } catch (err) {
  }
  
</script>




<script src="/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer:'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto',
    onClick: (e) => {
      $('.toc-link').removeClass('is-active-link');
      $(`a[href=${e.target.hash}]`).addClass('is-active-link');
      $(e.target.hash).scrollIntoView();
      return false;
    }
  });
</script>


<script>
  var ayerConfig = {
    mathjax: true
  }
</script>


<script src="/js/ayer.js"></script>


<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>



<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>


<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>
  </div>
</body>

</html>